#include <async_mqtt5.hpp>
#include <thread>
#include <functional>
#include <boost/asio/use_awaitable.hpp>

class MQTT
{
  public:
    struct ConnectInf
    {
      std::string clientID;
      std::string username;
      std::string password;
      std::string ipaddr;
      long port;
    };
  private:
    boost::asio::io_context ioc;
    async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket> client;
    bool runFlag=true;
    std::jthread netthread;
    void WorkThread(std::stop_token token);
    boost::asio::awaitable<void> channelDeviceConnect(const std::stop_token& token);
    boost::asio::awaitable<void> channelCameraControl();
    ConnectInf connInf;
  public:
    MQTT();
    virtual ~MQTT();
    void Boot(const ConnectInf& inf);
    std::function<void()> funcAllStartShot;
    std::function<void()> funcAllStopShot;
    std::function<bool()> funcAllShotStatus;
    std::function<std::vector<std::string>()> funcGetAllDevice;
};
